package model.object;

import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

import model.general.LoadImage;
import model.general.Location;
import model.general.Util;
import model.move.IMove;

public abstract class ObjectAnimate implements IObjectAnimate {
	protected Location location;
	protected String srcImg;
	protected BufferedImage img;
	protected IMove move;
	protected LoadImage loadImage = new LoadImage();
	protected int width = Util.DEFAULT_WIDTH, height = Util.DEFAULT_HEIGHT;
	protected JPanel pnl;

	protected Rectangle rect;

	public ObjectAnimate(int x, int y, String srcImg) {
		this.location = new Location(x, y);
		this.srcImg = srcImg;
		this.img = loadImage.getbufferImage(srcImg);
		this.width = img.getWidth();
		this.height = img.getHeight();
		rect = new Rectangle(x, y, width, height);
	}

	public Rectangle getBounds() {
		return rect;
	}

	public JPanel getPnl() {
		return pnl;
	}

	public void setPnl(JPanel pnl) {
		this.pnl = pnl;
	}

	@Override
	public void show(Graphics g) {
		g.drawImage(img, location.getX(), location.getY(), null);
	}

	public abstract boolean hasOutPanel();

	public abstract void updateLocation(Location loc);

	public abstract void reset();
}
